﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PatientManager.aspx.cs" Inherits="RegisterWeb.Manager.PatientManager.PatientManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/plugins/jquery.datagrid.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/datagrid-detailview.js" type="text/javascript"></script>
    <style type="text/css">
        
	.dv-table td{
		border:0;
	}
	.dv-label{
		font-weight:bold;
		color:#15428B;
		width:150px;
	}
</style>

<script type="text/javascript">

    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

    $(function () {
        $('#dg').datagrid({
            view: detailview,
            detailFormatter: function (index, row) {
                return '<div id="ddv-' + index + '" style="padding:5px 0"></div>';
            },
            onExpandRow: function (index, row) {
                
                $('#ddv-' + index).panel
                ({
                    border: false,
                    cache: false,
                    href: 'ShowManager.aspx',
                    onLoad: function () {
                        $('#dg').datagrid('fixDetailRowHeight', index);

                        $("#Name").text(row.Name);
                        $("#IDCrad").text(row.IDCrad);
                        $("#UserType").text(row.UserType);
                        $("#NotComeTime").text(row.NotComeTime);
                        $("#AddTime").text(row.AddTime);
                        $("#Phone").text(row.Phone);
                        $("#BirthDay").text(row.BirthDay);
                        $("#Sex").text(row.Sex);
                        $("#Mail").text(row.Mail);
                        $("#MedicareCard").text(row.MedicareCard);
                        $("#RrgIP").text(row.RrgIP);

                    }

                });
                $('#dg').datagrid('fixDetailRowHeight', index);
            }
        });

        $("#EditPatient").dialog('refresh');
        $("#EditPatient").dialog({
            "title": "用户等级修改",
            width: 600,
            height: 400,
            href: 'EditPatient.aspx'
        });
        $("#EditPatient").dialog('open').dialog('close');

        $('#dg').datagrid({

            onDblClickRow: function (rowIndex, rowData) {
                $('#EditPatient').dialog('open');
                $("#Name").text(rowData.Name);
                $("#MyUserType").combobox('setValue', rowData.UserType);

                url = 'ashx/PatientManagerServer.ashx?action=edit&&Id=' + rowData.ID;
                formId = "#edit";
                dialogId = "#EditPatient";
            }
        });
    });


    //用户等级修改
    function editPatient() {

        var row = $('#dg').datagrid('getSelected');
        if (row) {

            $('#EditPatient').dialog('open');
            $("#Name").text(row.Name);
            $("#MyUserType").combobox('setValue', row.UserType);

            url = 'ashx/PatientManagerServer.ashx?action=edit&Id=' + row.ID;
            formId = "#edit";
            dialogId = "#EditPatient";

        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");
        }
    }

    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            
            success: successCallback
        });
    }

    //多条件查询方法
    function tsearch() {
        var UserType = $("#MyUserType1").combobox("getValue");
        var Box_NotComeTime = $("#Box_NotComeTime").val();
        var Begin = $("#Begin").datebox("getValue");
        var End = $("#End").datebox("getValue");
        $('#dg').datagrid('options').pageNumber = 1;
        $('#dg').datagrid('getPager').pagination({ pageNumber: 1 });
        $('#dg').datagrid('options').url = 'ashx/PatientManagerServer.ashx?action=search&NotComeTime=' + Box_NotComeTime + '&UserType=' + UserType + '&Begin=' + Begin + '&End=' + End;
        $('#dg').datagrid("reload");
    }

</script>

</head>
<body>
    <form id="form1">
    <div region="center" title="患者用户管理" >
<table id="dg" title="患者用户管理"  style="overflow:auto; height:550px"
			url="ashx/PatientManagerServer.ashx?action=list"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true"   idField='ID'
            pageSize="20"
            >
		<thead>
			<tr>
				<th field="ID" width="40">编号</th>
				<th field="Name" width="40">用户名</th>
                <th field="IDCrad" width="90">身份证号</th>
				<th field="UserType" width="40" hidden='true'>用户类型</th>
                <th field="TextUserType" width="40">用户类型</th>
				<th field="NotComeTime" width="40">挂号未到次数</th>
                <th field="AddTime" width="40">注册时间</th>

                <th field="Phone"hidden='true'>手机号</th>
                <th field="BirthDay"  hidden='true'>出生年月</th>
                <th field="Sex" hidden='true'>性别</th>
                <th field="Mail" hidden='true'>邮箱地址</th>
                <th field="MedicareCard"  hidden='true'>医保卡</th>
                <th field="RrgIP" width="40" hidden='true'>注册时IP</th>
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editPatient()">用户等级修改</a>
		</div>
		<div>
			注册时间: <input class="easyui-datebox" style="width:80px" id="Begin">
			到: <input class="easyui-datebox" style="width:80px" id="End">
            
            挂号未到次数: 
			<input type="text" id="Box_NotComeTime" class="easyui-validatebox" />
			用户类型: 
			<select name="MyUserType1" id="MyUserType1" style="width:150px;">
            </select>
              <script type="text/javascript">

                  $('#MyUserType1').combobox({
                      url: 'ashx/PatientManagerServer.ashx?action=UserType',
                      valueField: 'SystemParameter_ID',
                      textField: 'SystemParameter_Name',
                      panelHeight: "auto"
                  });
             
            </script>
            
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="tsearch()">查询</a>
		</div>
	</div>

         <div id="EditPatient" class="easyui-dialog" closed="true" buttons="#EditPatient-buttons" style="padding:10px 20px">
        	</div>
			<div id="EditPatient-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#EditPatient').dialog('close')">关闭</a>
		    </div>
    </div>
    </form>
</body>
</html>
